package com.leihao.product.service.impl;

import com.leihao.common.core.exception.ServiceException;
import com.leihao.product.domian.ServiceGuarantee;
import com.leihao.product.mapper.ServiceGuaranteeMapper;
import com.leihao.product.service.ServiceGuaranteeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ServiceGuaranteeServiceImpl implements ServiceGuaranteeService {
    @Autowired
    private ServiceGuaranteeMapper serviceGuaranteeMapper;
    @Override
    public List<ServiceGuarantee> findAll() {
        return serviceGuaranteeMapper.findAll();
    }

    @Override
    public void add(ServiceGuarantee serviceGuarantee) {
            if (serviceGuarantee == null){
                throw new ServiceException("参数错误");
            }
            serviceGuaranteeMapper.add(serviceGuarantee);
    }

    @Override
    public void delete(Integer serviceGuaranteeId) {
        if (serviceGuaranteeId == null){
            throw new ServiceException("参数错误,编号不能为空");
        }
        serviceGuaranteeMapper.delete(serviceGuaranteeId);
    }

    @Override
    public void update(ServiceGuarantee serviceGuarantee) {
        if (serviceGuarantee == null){
            throw new ServiceException("参数错误");
        }
        if (serviceGuarantee.getServiceGuaranteeId() == null){
            throw new ServiceException("参数错误,编号不能为空");
        }
        serviceGuaranteeMapper.update(serviceGuarantee);
    }
}
